﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="System_Option.aspx.cs" Inherits="ncp.Web.cms.System_Option" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../../themes/icon.css" />
	<script type="text/javascript" src="../../js/jquery-1.7.1.min.js"></script>
	<script type="text/javascript" src="../../js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../js/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="../../../js/common.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <div style="font-size:12px;">
	        <table width="100%" cellpadding="3" cellspacing="0" border="0">
	            <tr>
                    <td>
                        <span style="padding:10px;">SMTP服务器：</span><input id="txtsmtp_server" type="text" maxlength="80" />
                    </td>
	            </tr>
	            <tr>
	                <td>
	                    <span style="padding:10px;">发件人Email：</span><input id="txtsmtp_username" type="text" maxlength="80" />
	                </td>
	            </tr>
	            <tr>
	                <td>
	                    <span style="padding:10px;">发件人密码：</span><input id="txtsmtp_pwd" type="password" maxlength="15" />
	                </td>
	            </tr>
	            <tr>
	                <td align="center">
	                    <a href="#" class="easyui-linkbutton" onclick="onSave();">保存</a>
	                </td>
	            </tr>
	        </table>
		</div>
    </form>
</body>
</html>
<script type="text/javascript">

    $(function() {
        LoadUserInfo();
    });
    
    //装载用户信息视图
    function LoadUserInfo() {
        var response = ncp.Web.cms.System_Option.BindTable();
        if (response.value != null) {
            var jsonOBJ = eval(response.value)[0];
                $("#txtsmtp_server").val(jsonOBJ.smtp_server);
                $("#txtsmtp_username").val(jsonOBJ.smtp_username);
                $("#txtsmtp_pwd").val(jsonOBJ.smtp_pwd);
        }
    }
    
    //保存用户信息
    function onSave() {
        if ($("#txtsmtp_server").val() == "") {
            alert("SMTP服务器不能为空！");
            return false;
        }
        if ($("#txtsmtp_username").val() == "") {
            alert("发件人Email不能为空！");
            return false;
        }
        if ($("#txtsmtp_pwd").val() == "") {
            alert("发件人密码不能为空！");
            return false;
        }
        var obj = new Object();
        obj.smtp_server = $("#txtsmtp_server").val();
        obj.smtp_username = $("#txtsmtp_username").val();
        obj.smtp_pwd = $("#txtsmtp_pwd").val();

        var jsonStr = $.objectToJson(obj);
        var response = ncp.Web.cms.System_Option.SaveSystemOption(jsonStr);
        if (response.value != null) {
            var jsonOBJ = eval(response.value)[0];
            alert(jsonOBJ.msg);
        }
        return false;
    }
</script>